<?php
/**
 * Switch
 *
 * The switch statement is similar to a series of IF statements on the
 * same expression. In many occasions, you may want to compare the same
 * variable (or expression) with many different values, and execute
 * a different piece of code depending on which value it equals to.
 * This is exactly what the switch statement is for.
 *
 * @author  Badrus Said <badrus.said@gmail.com>
 * @since   gop1.0
 */
final class gop_Switch extends gop_BaseIterator {
    public function execute(gop_Base $_caller = null) {
        if ($this->getReturn()) return;
        $this->setCaller($_caller);
        $C = $this->getContext()->getCallee($this->_inp["G1"])->execute($this);
        if ($C && isset($this->_inp["G2"][$C])) {
            $gx = $this->_inp["G2"][$C];
            if (is_array($gx)) {
            foreach($gx as $x) {
                $this->getContext()->getCallee($x)->execute($this);
                if ($this->_break) {
                    $this->interuptBreak();
                    break;
                }
                if ($this->_return) return;
            }} else {
                $this->getContext()->getCallee($T)->execute();
                if ($this->_return) return;
            }
        } else {
            if (isset($this->_inp["G3"])) {
                $this->getContext()->getCallee($this->_inp["G3"])->execute($this);
                if ($this->_return) return;
            }
        }
        $this->chainExec();
    }
}
?>